package gretha.modelsDeJTable;

import gretha.donnees.CohorteDuMassif;
import javax.swing.table.AbstractTableModel;

public class CohortesDuMassifTableModel extends AbstractTableModel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1592843038453885071L;
	private CohorteDuMassif[] donnees;
	private String[] enTetes = {"Parcelle","Cohorte","Quantite","Age"};

	public CohortesDuMassifTableModel(CohorteDuMassif[] data) {
		super();
		donnees = data;
	} 
	
	@Override
	public int getColumnCount() {
		return enTetes.length;
	}

	@Override
	public int getRowCount() {
		return donnees.length;
	}

	public String getColumnName(int columnIndex) {
		return enTetes[columnIndex];
	}
	
	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		switch ( columnIndex ) {
		case 0 : return new Integer(donnees[rowIndex].getNumeroParcelle());
		case 1 : return new String(donnees[rowIndex].getCohorte().getNom());
		case 2 : return new Integer(donnees[rowIndex].getQuantite());
		case 3 : return new Integer(donnees[rowIndex].getAge());
		}
		return "";
	}
	
	public boolean isCellEditable(int rowIndex, int columnIndex) {
		return false;
	}

	public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
	}
	
	public Class<? extends Object> getColumnClass(int columnIndex) {
		switch(columnIndex){
		case 0:
			return Integer.class;
		case 1:
			return String.class;
		case 2:
			return Integer.class;
		case 3:
			return Integer.class;
		default:
			return Object.class;
		}
	}

}
